package atom;


/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : AtomDemo
 * @Author : 54061
 * @Date: 2022/2/16 20:39
 */
public class AtomDemo {
    public static void main(String[] args) {
        Target target = new Target();
        for (int i= 0 ; i < 100;i++){
            new Thread(target).start();
        }
    }
}
class Target implements Runnable{
    private  int count=0;

    @Override
    public void run() {
        for (int i =0 ; i <100 ;i++){
            //从共享数据中读取数据到本线程栈中
            //修改本线程栈中变量副本的值
            //会把本线程中变量副本的值给共享数据
            count++;//非原子性的操作
            System.out.println("已经送了"+count+"个冰淇淋");
        }
    }
}